Role of the alt Attribute in <img>
The alt attribute in the <img> tag provides alternative text for an image. This text is displayed if the image cannot be loaded and is also used by screen readers to describe the image to visually impaired users.
It improves accessibility by giving screen readers a description of the image.
It is shown when the image fails to load (e.g., broken link or slow internet).
It helps search engines understand the content of images, improving SEO.
If the image is decorative and not essential, the alt attribute can be left empty (alt="").
In short: The alt attribute provides alternative text for images, making web pages more accessible and user-friendly.